<template>
  <div class="edit-tool">
    <div class="tool-view">
      <!-- <div class="item">
        <div class="title">扫描汇报</div>
        <el-image class="image" :src="codeImageUrl()" fit="cover"></el-image>
      </div> -->
      <div class="item">
        <div class="title">查看图纸</div>
        <el-image
          class="image"
          :src="drawingImgUrl"
          fit="cover"
          :previewSrcList="[drawingImgUrl]"
        >
        </el-image>
      </div>
    </div>
    <div class="tool-button">
      <div
        class="button"
        @click="routeClick('汇报记录')"
        :style="Tips == '汇报记录' ? 'z-index:9999' : 'z-index:1'"
      >
        汇报记录
      </div>
      <div
        class="button"
        @click="routeClick('领料记录')"
        :style="Tips == '领料记录' ? 'z-index:9999' : 'z-index:1'"
      >
        领料记录
      </div>
      <div
        class="button"
        @click="routeClick('检验记录')"
        :style="Tips == '检验记录' ? 'z-index:9999' : 'z-index:1'"
      >
        检验记录
      </div>
      <div
        class="button"
        @click="routeClick('转出记录')"
        :style="Tips == '出记录' ? 'z-index:9999' : 'z-index:1'"
      >
        转出记录
      </div>

      <el-dialog
        v-model="dialogVisible"
        :title="Tips"
        width="1400"
        :close-on-click-modal="false"
      >
        <processReport v-if="Tips == '汇报记录'" :codeNo="props.codeNo" />
        <productionForecastSheet
          v-else-if="Tips == '领料记录'"
          :codeNo="props.codeNo"
        />
        <inspectionSheet
          v-else-if="Tips == '检验记录'"
          :codeNo="props.codeNo"
        />
        <processTransfer
          v-else-if="Tips == '转出记录'"
          :codeNo="props.codeNo"
        />
      </el-dialog>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
import { drawingIdApi } from "@/api/system";
import processReport from "@/views/process-report/index.vue";
import productionForecastSheet from "@/views/production-forecast-sheet/index.vue";
import inspectionSheet from "@/views/inspection-sheet/index.vue";
import processTransfer from "@/views/process-transfer/index.vue";

const imgSrc = import.meta.env.VITE_APP_FILE_API;
const props = defineProps({
  codeNo: undefined,
  drawingId: "",
});

const drawingImgUrl = ref("");
const getDrawingIdApi = async () => {
  if (!props.drawingId) return;
  const res = await drawingIdApi(props.drawingId);
  drawingImgUrl.value = imgSrc + res.data.link;
};
getDrawingIdApi();
// 二维码文件
const codeImageUrl = () => {
  return new URL(`@/assets/images/qrCode.png`, import.meta.url).href;
};

// 图纸文件
const drawingImageUrl = () => {
  return new URL(`@/assets/images/qrCode.png`, import.meta.url).href;
};

const dialogVisible = ref(false);
const Tips = ref("");
// const router = useRouter();
const routeClick = (name) => {
  // router.push({ path, query: { codeNo: props.codeNo } });
  if (Tips.value === name) {
    dialogVisible.value = false;
    Tips.value = "";
    return;
  }
  dialogVisible.value = true;
  Tips.value = name;
};
</script>

<style lang="scss" scoped>
.edit-tool {
  display: flex;
  align-items: center;
  .tool-view {
    background-color: #f2f2f2;
    height: 600px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    .item {
      display: flex;
      flex-direction: column;
      justify-items: center;
      align-items: center;
      .title {
        margin-bottom: 15px;
      }
      .image {
        width: 200px;
        height: 200px;
      }
    }
  }
  .tool-button {
    height: 600px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    margin-left: 20px;
    .button {
      box-sizing: border-box;
      background-color: #469ad0;
      padding: 35px 5px;
      writing-mode: vertical-lr;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 8px;
      color: white;
      cursor: pointer;
      position: relative;
    }
  }
}
</style>
<style>
.tool-button .el-overlay-dialog {
  justify-content: end !important;
}
.tool-button .el-dialog {
  margin: 0 !important;
  margin-right: 80px !important;
  min-height: 600px;
}
</style>